﻿<%@ WebHandler Language="C#" Class="ArticlePublish" %>

using System;
using System.Web;
using System.Web.SessionState;
public class ArticlePublish : IHttpHandler,IReadOnlySessionState {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        UserHelper u = new UserHelper();
        string title = context.Request["Title"];
        string Content = context.Request["textContent"];
        int classNum=Convert.ToInt32(context.Request["class"]);
        string name=null;
        try
        {
            name = context.Session["name"].ToString();
            if (u.AdminPublish(title, Content, name, classNum, 0))
            {
                context.Response.Write(1);
            }
            else
            {
                context.Response.Write(0); 
            }
        }
        catch
        {
            context.Response.Write(0); 
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}